<?php include("../../data/mysql.class.php")?>
<?php include("../../data/Function.php")?>
<?php include("../info.php") ?>
<?
    if(isset($_POST["Type"])){
        $Type=$_POST["Type"];
    }else{
        $Type="error";
    }

	
	$conn=new Mysql();
	switch($Type){
		case "delete":
		if($conn->query("delete from d_shop where id =".$_POST["id"])){
			echo 1;
			}else{
				echo 0;
				}
		break;
		case "up":
            $connt = new Mysql();
            $sql = "select max(id) as maxid from d_shop ";
            $rs =$conn->getRow($sql);
            if($rs) {
                $rsid = intval($rs["maxid"])+1;
            }else{
                $rsid="1";
            }
            $p_id=str_pad($rsid,4,"0",STR_PAD_LEFT );
            $s_id=$p_id;
            $s_name=$_POST["s_name"];
            $s_manage_id=$_POST["s_manage_id"];
            $s_address=$_POST["s_address"];
            $s_areaid=$_POST["s_areaid"];
            $s_tel=$_POST["s_tel"];
            $istate=$_POST["istate"];
            $s_logo=$_POST["s_logo"];
            $s_urls=$SiteUrl."shop/".$p_id."/";
            if($conn->query("insert into d_shop(s_id,s_name,s_manage_id,s_address,s_areaid,s_tel,s_urls,s_logo,istate,adate) values($s_id,'$s_name',$s_manage_id,'$s_address',$s_areaid,'$s_tel','$s_urls','$s_logo',1,'".now()."')")){
                echo 1;
            }else{
               echo 0;
                // echo "insert into d_shop(s_id,s_name,s_manage_id,s_address,s_areaid,s_tel,s_urls,istate,adate) values($s_id,'$s_name',$s_manage_id,'$s_address',$s_areaid,'$s_tel','$s_urls',1,'".now()."')";
            }
		break;
        case "edit":
            $s_name=$_POST["s_name"];
            $s_manage_id=$_POST["s_manage_id"];
            $s_address=$_POST["s_address"];
            $s_areaid=$_POST["s_areaid"];
            $s_tel=$_POST["s_tel"];
            $id=$_POST["sid"];
            $s_logo=$_POST["s_logo"];
            $conn=new Mysql();
            if($conn->query("update d_shop set s_name='$s_name',s_manage_id=$s_manage_id,s_address='$s_address',s_areaid=$s_areaid,s_tel='$s_tel',s_logo='$s_logo' where id=".$id)){

                echo 1;}else{
                echo 0;
            }
            break;
        case "checkstate":
            if($conn->query("update  d_shop set istate=".$_POST["isstate"]." where id =".$_POST["id"])){
                echo 1;
            }else{
                echo 0;
            }
            break;
		default:
		break;
		}
?>